﻿/***********************************************************************************************
 * 
 * ProjectName: WMSSoft.Lib.WinKStart
 * 
 * Description: Enum and Convert Class to work with XML horizontalAlign 
 * 
 * Created:     22.07.2012
 * 
 * Author:      matthias wagler - matthias@WMSSoft.de
 * 
 * Copyright:   Copyright 2012 by WMSSoft.de
 * 
 * Lizense:     GPLv3
 * 
 * History:     22.07.2012 - matthias wagler matthias@WMSSoft.de   -   Created
 * 
 **********************************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WMSSoft.Lib.WinKStart
{
    /// <summary>
    /// Use the enum to describe inner vertical align for a ListboxItem
    /// </summary>
    public enum eXMLVerticalAlign
    { 
        /// <summary>
        /// The Align is unknown
        /// </summary>
        Unknown = 0,

        /// <summary>
        /// Pos it on Top
        /// </summary>
        Top = 1,

        /// <summary>
        /// Pos it in the middle
        /// </summary>
        Center,

        /// <summary>
        /// Pos it on Bottom
        /// </summary>
        Bottom
    }

    /// <summary>
    /// Methods to convert a string into a eXMLVerticalAlign or a eXMLVerticalAlign into an string
    /// </summary>
    public static class cXMLVerticalAlign
    {
        /// <summary>
        /// Methode convert a string into an eXMLVerticalAlign
        /// </summary>
        /// <param name="Value">string to convert</param>
        /// <returns>eXMLVerticalAlign, Unknown if value has no enum align</returns>
        public static eXMLVerticalAlign GetEnumValueFromString(string Value)
        {
            try
            {
                if (Value.ToUpper() == "TOP") return eXMLVerticalAlign.Top;
                else if (Value.ToUpper() == "CENTER") return eXMLVerticalAlign.Center;
                else if (Value.ToUpper() == "BOTTOM") return eXMLVerticalAlign.Bottom;
                else return eXMLVerticalAlign.Unknown;
            }
            catch
            {
                return eXMLVerticalAlign.Unknown;
            }
        }

        /// <summary>
        /// Converts a eXMLVerticalAlign into a string
        /// </summary>
        /// <param name="Value">eXMLVerticalAlign VAlue</param>
        /// <returns>string equivalent to value</returns>
        public static string GetStringFromEnum(eXMLVerticalAlign Value)
        {
            try
            {
                switch (Value)
                {
                    case eXMLVerticalAlign.Bottom: return "Bottom";
                    case eXMLVerticalAlign.Center: return "Center";
                    case eXMLVerticalAlign.Top: return "Top";
                    default: return "Unknown";                        
                }
            }
            catch
            {
                return "Unknown";
            }
        }
    }
}
